﻿package com.glaivelee;
import java.sql.*;

public class DBConnection
{
    private String driver;
    private StringBuffer accessURL;
    private String accessFilePath;
    private String accessFileName;
    private Connection conn;
    private String DBRealPath;

	public DBConnection()
    {
    	System.out.println("");
    	driver = "sun.jdbc.odbc.JdbcOdbcDriver";
        accessURL = new StringBuffer("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=");
        setAccessFilePath("");
        setAccessFileName("");
        conn = null;
    }

    public Connection getConnectionToAccess(String s)
        throws SQLException, ClassNotFoundException
    {
        accessURL.append(s);
        Class.forName(driver);
        conn = DriverManager.getConnection(accessURL.toString());
        return conn;
    }

    public void close()
    {
        try
        {
            conn.close();
        }
        catch(SQLException sqlexception)
        {
            sqlexception.printStackTrace();
        }
    }

	public void setAccessFilePath(String accessFilePath) {
		this.accessFilePath = accessFilePath;
	}

	public String getAccessFilePath() {
		return accessFilePath;
	}

	public void setAccessFileName(String accessFileName) {
		this.accessFileName = accessFileName;
	}

	public String getAccessFileName() {
		return accessFileName;
	}

	public String getDBRealPath() {
		return DBRealPath;
	}
	
}